<?php
class Support extends Controller {

	function Support() {

		parent::Controller();
		$this->load->model('model_support');

		//verificare sesiune
		if (!$this->usersession->userLoggedIn()) {
			$aResponse = array(
				"error" => true,
				"description" => "Sesiunea a expirat",
				"type" => "nosession"
			);
			die(json_encode($aResponse));
		}
	}

	/**
	 * Functie care aduce datele in grid
	 */
	function getData() {
		echo json_encode($this->model_support->getData($_POST));
	}

	/**
	 * Functie de editare / inserare element
	 * @return string json
	 */
	function operation() {
		$aResponse = array(
			"error" => false,
			"success" => true,
			"description" => "Datele au fost salvate"
		);
		$this->model_support->operation($_POST);
		echo json_encode($aResponse);
	}

	/**
	 * Functie care aduce datele despre unei inregistrari
	 * @return string json
	 */
	function getRecord() {
		$aResult = $this->model_support->getRecord($_POST);
		echo json_encode(array(
			"error" => false,
			"data" => $aResult
		));
	}

}
